package com.example.personnel_oa.controller;

import com.example.comment_oa.pojos.Jobrequirements;
import com.example.comment_oa.pojos_vo.Talentpool_vo;
import com.example.comment_oa.response.AjaxResponse;
import com.example.personnel_oa.service.JobrequirementsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("personnelOa")
public class JobrequirementsController {
    @Autowired
    JobrequirementsService jobservice;

    //查询基本的岗位需求的数据
    @PostMapping("job/selectjob")
    public AjaxResponse selectjob(){
        List<Jobrequirements> selectjob = jobservice.selectjob();
        return AjaxResponse.success(selectjob);
    }
    //查询岗位需求条数
    @PostMapping("job/countJob")
    public AjaxResponse countJob(){
        int i = jobservice.countJob();
        return AjaxResponse.success(i);
    }
    //岗位需求的条件查询
    @PostMapping("job/selectAlljob")
    public AjaxResponse selectAlljob(@RequestBody Talentpool_vo talentpoolVo){
        List<Jobrequirements> jobrequirements = jobservice.selectAlljob(talentpoolVo);
        return AjaxResponse.success(jobrequirements);
    }

    //根据id查询发布记录
    @PostMapping("job/fabujilu/{jobId}")
    public AjaxResponse fabujilu(@PathVariable("jobId") int jobId){
        List<Jobrequirements> fabujilu = jobservice.fabujilu(jobId);
        return AjaxResponse.success(fabujilu);
    }
    //根据id查询申请人信息
    @PostMapping("job/shrnqingren/{jobId}")
    public AjaxResponse shrnqingren(@PathVariable("jobId") int jobId){
        Jobrequirements shrnqingren = jobservice.shrnqingren(jobId);
        return AjaxResponse.success(shrnqingren);
    }
    //新增一条需求数据
    @PostMapping("job/addjob")
    public AjaxResponse addjob(@RequestBody Jobrequirements job){
        int addjob = jobservice.addjob(job);
        return AjaxResponse.success(addjob);
    }
    //根据id查询需求数据
    @PostMapping("job/selectjobId/{jobId}")
    public AjaxResponse selectjobId(@PathVariable("jobId") int jobId){
        Jobrequirements jobrequirements = jobservice.selectjobId(jobId);
        return AjaxResponse.success(jobrequirements);
    }
    //发布功能，修改状态
    @PostMapping("job/upstatus/{jobId}")
    public AjaxResponse upstatus(@PathVariable("jobId") int jobId){
        int upstatus = jobservice.upstatus(jobId);
        return AjaxResponse.success(upstatus);
    }
    //修改岗位需求数据
    @PutMapping("jib/uptJob")
    public AjaxResponse uptJob(@RequestBody Jobrequirements job){
        int i = jobservice.upJob(job);
        return AjaxResponse.success(i);
    }
    //撤回功能，修改状态
    @PostMapping("job/upstatus2/{jobId}")
    public AjaxResponse upstatus2(@PathVariable("jobId") int jobId){
        int upstatus = jobservice.upstatus2(jobId);
        return AjaxResponse.success(upstatus);
    }
    //重新发布功能，修改状态
    @PostMapping("job/upstatus3/{jobId}")
    public AjaxResponse upstatus3(@PathVariable("jobId") int jobId){
        int upstatus = jobservice.upstatus3(jobId);
        return AjaxResponse.success(upstatus);
    }
    //关闭发布功能，修改状态
    @PostMapping("job/upstatus4/{jobId}")
    public AjaxResponse upstatus4(@PathVariable("jobId") int jobId){
        int upstatus = jobservice.upstatus4(jobId);
        return AjaxResponse.success(upstatus);
    }
    //流程查看用工需求申请，根据编号查询数据
    @PostMapping("job/bianhao/{jobBianhao}")
    public AjaxResponse bianhao(@PathVariable("jobBianhao") String jobBianhao){
        Jobrequirements bianhao = jobservice.bianhao(jobBianhao);
        return AjaxResponse.success(bianhao);
    }

}
